package argirithm;

import java.util.Arrays;

/**
 * 2分查找测试
 * */
public class Demo06 {
    public static void main(String[] args) {
        int[] arr = {3,6,9,15,35,66,66,66,99,120,138,168,189,211};
        //找到了
        int index = Arrays.binarySearch(arr,66);//6
        System.out.println(index);
        //找不到
        index=Arrays.binarySearch(arr,888);
        System.out.println(index);
        index=Arrays.binarySearch(arr,1);
        System.out.println(index);
        index=Arrays.binarySearch(arr,100);
        System.out.println(index);

    }
}
